<template>
  <div id="app">
    <li>
      <label>
        <input type="checkbox" :checked="todos.done" @change="handleCheck(todos.id)"/>
        <span>{{todos.name}}</span>
      </label>
      <button class="btn btn-danger" @click="handleDelete(todos.id)">删除</button>
    </li>
  </div>
</template>
<script>
export default {
  name: "MyItem",
  props:['todos','changeTodo','deleteTodos'],
  methods:{
    handleCheck(id){
      this.changeTodo(id)
    },
    //删除一个todos
    handleDelete(id){
      //需要app来进行删除
      if(confirm("确定")){
        this.deleteTodos(id)
      }
      
      // console.log("当前获得的id是",id)

    }
  }
};
</script>
<style scoped>
/*item*/
li {
  list-style: none;
  height: 36px;
  line-height: 36px;
  padding: 0 5px;
  border-bottom: 1px solid #ddd;
}

li label {
  float: left;
  cursor: pointer;
}

li label li input {
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -1px;
}

li button {
  float: right;
  display: none;
  margin-top: 3px;
}

li:before {
  content: initial;
}

li:last-child {
  border-bottom: none;
}
/* 移动到对应的列后，背景色变为灰色 */
li:hover{
  background:#ddd;
}
/* 悬浮的时候出现button */
li:hover button{
  display:block;
}
</style>
